/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controleur;

import Modele.Incident;
import Modele.Technicien;
import Modele.TypeIncident;
import Modele.Velo;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author 20cent
 */
public class IncidentTableModel extends AbstractTableModel {

    private ArrayList<Incident> incidents;
    public static final String[] COLONNES = {"ID",
        "Numéro vélo",
        "Type Incident",
        "Assigné à ",
        "Date ouverture",
        "Date fermeture",
        "Statut",
        "Pirorité"};

    public IncidentTableModel(ArrayList<Incident> incidents) {
        this.incidents = incidents;
    }

    public void setIncidents(ArrayList<Incident> incidents) {
        this.incidents = incidents;
        fireTableDataChanged();
    }

    @Override
    public int getRowCount() {
        return incidents.size();
    }

    @Override
    public int getColumnCount() {
        return COLONNES.length;
    }

    @Override
    public String getColumnName(int column) {
        return COLONNES[column];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Incident incident = incidents.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return incident.getMId();
            case 1:
                return incident.getmVelo();
            case 2:
                return incident.getmTypInc();
            case 3:
                return incident.getmTechnicien();
            case 4:
                return incident.getMDateOuverture();
            case 5:
                return incident.getMDateFermeture();
            case 6:
                return incident.getMStatut();
            case 7:
                return incident.getIncidentProrite();
            default:
                return null;
        }
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        switch (columnIndex) {
            case 0:
                return int.class;
            case 1:
                return Velo.class;
            case 2:
                return TypeIncident.class;
            case 3:
                return Technicien.class;
            case 4:
                return Date.class;
            case 5:
                return Date.class;
            case 6:
                return String.class;
            case 7:
                return String.class;
            default:
                return null;
        }
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }
    
}
